import React, { Component } from 'react'
import moment from "moment"
export default class Time extends Component {
    state = {
        timeuser: 20

    }
    timeclear = null
    componentDidMount() {
        this.timeclear = setInterval(() => {
            this.setState({
                timeuser: moment().format("YYYY-MM-DD HH:mm:ss")
            })

        }, 1000)
    }
    componentWillUnmount() {
        console.log(this);
        console.log("变了");
        clearInterval(this.timeclear)

    }
    render() {
        return (
            <div style={{ width: 300, height: 100, border: "1px solid", margin: "auto", textAlign: "center" }}>
                {this.state.timeuser}
              <h4>11</h4>
            </div>
        )
    }
}
